// pages/success/success.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    sum: "",
    time: "",
    datelists: "",
    paid:'',
    zifu:'',
    null : '',
  },
  success() {
    wx.switchTab({
      url: '/pages/my/my',
    })
  },
  getsum() {
    let num = Math.floor(Math.random() * 1123).toString(16);

    function current() {
      var d = new Date(),
        str = '';
      str += d.getFullYear();
      str += (d.getMonth() + 1) > 10 ? (d.getMonth() + 1) : '0' + (d.getMonth() + 1);
      str += d.getDate() > 10 ? d.getDate() : '0' + d.getDate();
      str += d.getHours() > 10 ? d.getHours() : '0' + d.getHours();
      str += d.getMinutes() > 10 ? d.getMinutes() : '0' + d.getMinutes();
      str += d.getSeconds() > 10 ? d.getSeconds() : '0' + d.getSeconds();
      return str;
    }
    this.setData({
      sum: current() + num
    })
    this.gettime();
    this.getdatelists();
  },

  getdatelists() {
    function datelists() {
      var d = new Date(),
        str = '';
      str += d.getFullYear();
      str += (d.getMonth() + 1) > 10 ? (d.getMonth() + 1) + "-" : '0' + (d.getMonth() + 1) + "-";
      str += d.getDate() > 10 ? d.getDate() + "-" : '0' + d.getDate() + "  ";
      str += d.getHours() > 10 ? d.getHours() + "-" : '0' + d.getHours() + "-";
      str += d.getMinutes() > 10 ? d.getMinutes() + "-" : '0' + d.getMinutes() + "-";
      str += d.getSeconds() > 10 ? d.getSeconds() : '0' + d.getSeconds();
      return str;
    }
    this.setData({
      datelists: datelists()
    })
  },
  gettime() {
    function time() {
      var d = new Date(),
        str = '';
      str += d.getFullYear() + '.';
      str += (d.getMonth() + 1) > 10 ? (d.getMonth() + 1) + '.' : '0' + (d.getMonth() + 1) + '.';
      str += d.getDate() > 10 ? d.getDate() : '0' + d.getDate();
      return str;
    }
    this.setData({
      time: time()
      // sum : (Math.random().)*10000 * toString(16)
    })
    // console.log(this.data.time)
  },

  getpaid(){
    let zifu =  wx.getStorageSync('datalistsa')
    this.setData({
      zifu : zifu
    })
    wx.setStorageSync('zifu',this.data.zifu)
    // console.log(wx.getStorageSync('zifu'))
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getsum();
    // console.log(wx.getStorageSync('datalistsa'))
    this.getpaid();
    wx.setStorageSync('pay',this.data.null);
    wx.setStorageSync('GoodsCarList', this.data.null);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    wx.setStorageSync('ordernumber', this.data.sum);
    wx.setStorageSync('datelists', this.data.datelists);
    wx.setStorageSync('zifu',this.data.zifu);
    // console.log(this.data.sum)
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    // wx.setStorageSync('pay','')
  },
  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    wx.reLaunch({
      url: '/pages/my/my',
    })
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})